import request from "@/plugins/axios";
import { ProTableResult } from "tdesign-pro-component";

export function getSystemUserPage(data: any) {
    delete data.sort;
    return request.post<ProTableResult<SystemUserListVo>>('/api/system_user/page', data);
}

export function getSystemUser(id: number) {
    return request.get<GetUserInfoVo>('/api/system_user/' + id);
}

export function createSystemUser(data: {username: string, password: string}) {
    return request.post<any>('/api/system_user', data);
}

export function updateSystemUser(data: {username: string, password: string, id: number}) {
    return request.put<any>('/api/system_user', data);
}

export function deleteSystemUser(id: number) {
    return request.delete<any>('/api/system_user/' + id);
}

export function getRoleIdsByUserId(id: number) {
    return request.get<number[]>(`/api/system_user/user_role/${id}`)
}

export function saveUserRole(data: {userId: number, roleIds: number[]}) {
    return request.post(`/api/system_user/user_role`, data)
}